package com.xbongbong.paas.elasticsearch.pojo;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;

/**
 * 多层级聚合，时间聚合分桶 + terms聚合 + sum聚合 桶名及聚合字段名pojo
 * @author zcp
 * @version v1.0
 * @since v1.0
 */
@Getter
@Setter
@ToString
public class AggMorePojo implements Serializable {
    private static final long serialVersionUID = 8434760628986499310L;

    /**
     * 第一层时间聚合桶名
     */
    private String aggs;
    /**
     * 第二层聚合桶名
     */
    private String aggs2;
    /**
     * 第三层聚合桶名
     */
    private String aggs3;
    /**
     * 时间聚合字段
     */
    private String aggsFieldTime;
    /**
     * terms聚合字段
     */
    private String aggsTermsField;
    /**
     * terms聚合桶大小
     */
    private Integer aggsTermsSize;
    /**
     * sum聚合字段
     */
    private String aggsSumField;

    /**
     * 最终聚合结果（已经用“aggs01”读取第一层）
     * key：buckets、total
     */
    private JSONObject result;

    public AggMorePojo(String aggsFieldTime){
        this.aggs = "aggs01";
        this.aggsFieldTime = aggsFieldTime;
    }
    public AggMorePojo(String aggsFieldTime, String aggsTermsField, Integer aggsTermsSize, String aggsSumField){
        this.aggs = "aggs01";
        this.aggs2 = "aggs02";
        this.aggs3 = "aggs03";
        this.aggsFieldTime = aggsFieldTime;
        this.aggsTermsField = aggsTermsField;
        this.aggsTermsSize = aggsTermsSize;
        this.aggsSumField = aggsSumField;
    }
}
